Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LDAP grafana support #1013

Merged
merged 1 commit into from
Sep 22, 2020
Merged

Add LDAP grafana support #1013

merged 1 commit into from
Sep 22, 2020

Conversation

amnonh
Copy link
Collaborator

@amnonh amnonh commented Aug 3, 2020

Grafana supports LDAP for use authentication.
You can read more about grafana support here:
https://grafana.com/docs/grafana/latest/auth/ldap/

This patch adds a command line option -P to pass an ldap configuration
file to Grafana.

Note that to access your LDAP from Grafana you'll need to login as
admin.

Fixes #912

Signed-off-by: Amnon Heiman [email protected]

@amnonh
Copy link
Collaborator Author

amnonh commented Aug 3, 2020

@dyasny Can you take it for a spin?

@amnonh amnonh requested a review from dyasny August 3, 2020 15:06
@dyasny
Copy link

dyasny commented Aug 3, 2020

on my TODO for tomorrow

@dyasny
Copy link

dyasny commented Aug 4, 2020

@amnonh do you know who might have a working LDAP server up and available somewhere? I don't have one and would have to build something (AD? FreeIPA?). Maybe it's better to simply pass the test request t the QA folks, the same ones who test the LDAP integration with Scylla Enterprise

@amnonh
Copy link
Collaborator Author

amnonh commented Aug 4, 2020 via email

@dyasny
Copy link

dyasny commented Aug 4, 2020

$ docker run --env LDAP_ORGANISATION="Contoso" --env LDAP_DOMAIN="contoso.com" --env LDAP_ADMIN_PASSWORD="Bugaga123" --detach -p 389:389 -p 636:636 --name my-openldap-container osixia/openldap:1.4.0

$ ldapsearch -x -H ldap://172.17.0.1 -b dc=contoso,dc=com -D "cn=admin,dc=contoso,dc=com" -w Bugaga123
# extended LDIF
#
# LDAPv3
# base <dc=contoso,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# contoso.com
dn: dc=contoso,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: Contoso
dc: contoso

# admin, contoso.com
dn: cn=admin,dc=contoso,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
userPassword:: e1NTSEF9UUJCbk9jTENCanpNaXlaL0JBaDRmblB4SUt2MmpFeis=

# search result
search: 2
result: 0 Success

# numResponses: 3
# numEntries: 2

## IT WORKS


$ cat ldap.toml
[[servers]]
# Ldap server host (specify multiple hosts space separated)
host = "172.17.0.1"
# Default port is 389 or 636 if use_ssl = true
port = 389
# Set to true if LDAP server supports TLS
use_ssl = false
# Set to true if connect LDAP server with STARTTLS pattern (create connection in insecure, then upgrade to secure connection with TLS)
start_tls = false
# set to true if you want to skip SSL cert validation
ssl_skip_verify = false
# set to the path to your root CA certificate or leave unset to use system defaults
# root_ca_cert = "/path/to/certificate.crt"
# Authentication against LDAP servers requiring client certificates
# client_cert = "/path/to/client.crt"
# client_key = "/path/to/client.key"

# Search user bind dn
bind_dn = "cn=admin,dc=contoso,dc=com"
# Search user bind password
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
bind_password = 'Bugaga123'

# User search filter, for example "(cn=%s)" or "(sAMAccountName=%s)" or "(uid=%s)"
# Allow login from email or username, example "(|(sAMAccountName=%s)(userPrincipalName=%s))"
search_filter = "(cn=%s)"

# An array of base dns to search through
search_base_dns = ["dc=contoso,dc=com"]

# group_search_filter = "(&(objectClass=posixGroup)(memberUid=%s))"
# group_search_filter_user_attribute = "distinguishedName"
# group_search_base_dns = ["ou=groups,dc=grafana,dc=org"]

# Specify names of the LDAP attributes your LDAP uses
[servers.attributes]
name = "givenName"
surname = "sn"
username = "cn"
member_of = "memberOf"
email =  "email"

./start-all.sh -P $PWD/ldap.toml

## EVERYTHING STARTED

Logging into IP:3000 doesn't ask for a password.

The users tab in Grafana has no LDAP mentioned

image

Am I missing something?

@amnonh
Copy link
Collaborator Author

amnonh commented Aug 4, 2020 via email

@dyasny
Copy link

dyasny commented Aug 4, 2020

I am using the docker internal IPs for connectivity - 172.17.0.1 (it's in the config file)

@amnonh
Copy link
Collaborator Author

amnonh commented Aug 4, 2020

To see the LDAP configuration you need to login (the arrow at the bottom left) use admin/admin
It would add an option for server admin with LDAP.

Can you add the logs from:
docker logs agraf

More on the grafana ldap integration can be found here:
https://grafana.com/docs/grafana/latest/auth/ldap/

@amnonh
Copy link
Collaborator Author

amnonh commented Aug 12, 2020

@dyasny any updates?

Grafana supports LDAP for use authentication.
You can read more about grafana support here:
https://grafana.com/docs/grafana/latest/auth/ldap/

This patch adds a command line option `-P` to pass an ldap configuration
file to Grafana.

Note that to access your LDAP from Grafana you'll need to login as
admin.

Fixes scylladb#912

Signed-off-by: Amnon Heiman <[email protected]>
@amnonh amnonh merged commit dfdc014 into scylladb:master Sep 22, 2020
@amnonh amnonh deleted the ldap_support branch September 22, 2020 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFE: Add support for LDAP auth in grafana
2 participants